<?php
require_once WEB_MODEL_DIR . DIRECTORY_SEPARATOR . 'DAO' . DIRECTORY_SEPARATOR . 'TelcoPromotionDAO.php';
class TelcoPromotionService {

	public function getTelcoPromotion($context, $result) {
        $telcoPromotionArr = null;
        try {
            $telcoPromotionDAO = new TelcoPromotionDAO($context);

            $telcoPromotionArr = $telcoPromotionDAO -> getTelcoPromotion();
            if (isset($telcoPromotionArr) && !empty($telcoPromotionArr)) {
                $result -> setSuccess();
            } else {
                $result -> setFailed("ERR01", "No App Found");
                $context -> logError("ERR01", "No App Found Call By " . __METHOD__ . " ON " . __CLASS__);
            }
        } catch (Exception $e) {
            $result -> setException($e);
            $context -> logException($e);
        }

        return $telcoPromotionArr;
    }
    
	public function insertTelcoPromotion($context, $result,$param) {
        $telcoPromotionArr = null;
        try {
            $telcoPromotionDAO = new TelcoPromotionDAO($context);

            $telcoPromotionArr = $telcoPromotionDAO -> insertTelcoPromotion($param);
        } catch (Exception $e) {
            $result -> setException($e);
            $context -> logException($e);
        }
        return $telcoPromotionArr;
    }
    
	public function updateTelcoPromotion($context, $result,$param) {
        $telcoPromotionArr = null;
        try {
            $telcoPromotionDAO = new TelcoPromotionDAO($context);

            $telcoPromotionArr = $telcoPromotionDAO -> updateTelcoPromotion($param);
        } catch (Exception $e) {
            $result -> setException($e);
            $context -> logException($e);
        }
        return $telcoPromotionArr;
    }
    
	public function deleteTelcoPromotion($context, $result, $id) {
        try {

            $telcoPromotionDAO = new TelcoPromotionDAO($context);

            $telcoPromotionDAO -> deleteTelcoPromotion($id);
        } catch (Exception $e) {
            $result -> setException($e);
            $context -> logException($e);
        }
    }
}
?>